package com.jy.rhin.facade.controller.document;


import com.jy.framework.base.entity.Page;
import com.jy.framework.base.entity.Result;
import com.jy.rhin.facade.controller.document.dto.DocumentStatisticsCountDto;
import com.jy.rhin.infra.repo.document.submission.query.DocumentStatisticsQueryHandler;
import com.jy.rhin.sdk.dto.document.statistic.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dhl
 * @date 2022/6/13
 * @Description
 */
@RestController
@RequestMapping("/documentStatistics")
@Api(tags = "文档统计")
@Slf4j
public class DocumentStatisticsBizController {

    @Resource
    private DocumentStatisticsQueryHandler statisticsQueryHandler;

    @ApiOperation("/获取文档统计信息")
    @GetMapping("/queryDocumentStatic")
    public Result<DocumentStatisticsCountDto> queryDocumentStatic() {
        Long documentEntryTotal = statisticsQueryHandler.queryDocumentEntryTotal();
        DocumentStatisticsCountDto dto = new DocumentStatisticsCountDto()
                .setDocumentTotal(documentEntryTotal)
                .setSubmissionSetTotal(statisticsQueryHandler.queryDocumentSetTotal())
                .setDocumentEntryTotal(documentEntryTotal)
                .setDocumentEntryTotalByDay(statisticsQueryHandler.queryDocumentEntryTotalByDay());
        return Result.success(dto);
    }

    @ApiOperation("获取文档提交集总数")
    @GetMapping("/querySubmissionSetTotal")
    public Result<Long> queryDocumentSetTotal() {
        return Result.success(statisticsQueryHandler.queryDocumentSetTotal());
    }

    @ApiOperation("获取文档总数")
    @GetMapping("/queryDocumentEntryTotal")
    public Result<Long> queryDocumentEntryTotal() {
        return Result.success(statisticsQueryHandler.queryDocumentEntryTotal());
    }

    @ApiOperation("获取文档日增数")
    @GetMapping("/queryDocumentEntryTotalByDay")
    public Result<Long> queryDocumentEntryTotalByDay() {
        return Result.success(statisticsQueryHandler.queryDocumentEntryTotalByDay());
    }

    @ApiOperation("获取文档指定日期区间每日总数")
    @GetMapping("/queryDocumentEntryTotalGroupDay")
    public Result<List<GetTotalGroupDayRespDto>> queryDocumentEntryTotalGroupDay(GetTotalGroupDayReqDto dto) {
        return Result.success(statisticsQueryHandler.queryDocumentEntryTotalGroupDay(dto));
    }

    @ApiOperation("获取各类型文档总数以及日增数")
    @GetMapping("/queryDocumentEntryTotalGroupType")
    public Result<List<GetTotalGroupTypeRespDto>> queryDocumentEntryTotalGroupType() {
        return Result.success(statisticsQueryHandler.queryDocumentEntryTotalGroupType());
    }

    @ApiOperation("获取各医院文档总数以及日新增数")
    @GetMapping("/queryOrgListGroupOrgName")
    public Result<Page<FindOrgListRespDto>> queryOrgListGroupOrgName(FindOrgListReqDto dto) {
        return Result.success(statisticsQueryHandler.queryOrgListGroupOrgName(dto));
    }
}
